package com.sunwayworld.basemodule.basedata.experimentinfo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.basedata.experimentinfo.dao.LimsExperimentInformationDao;
import com.sunwayworld.basemodule.basedata.experimentinfo.bean.LimsExperimentInformationBean;
import com.sunwayworld.basemodule.basedata.experimentinfo.service.LimsExperimentInformationService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsExperimentInformationServiceImpl implements LimsExperimentInformationService {

    @Autowired
    private LimsExperimentInformationDao limsExperimentInformationDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsExperimentInformationDao getDao() {
        return limsExperimentInformationDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsExperimentInformationBean limsExperimentInformation = jsonWrapper.parseUnique(LimsExperimentInformationBean.class);
        limsExperimentInformation.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsExperimentInformation);
        return limsExperimentInformation.getId();
    }

}
